<?php

class Gcentrale_GprojetController extends Zend_Controller_Action
{

    public function init()
    {
        /* Initialize action controller here */
    }

    public function indexAction()
    {
        // action body
    }

    public function gestprojetAction()
    {
        // action body
    	// action body
    	$header=array(
    			"idprojetregional"=>"Code"
    			,"idgoverneras"=>"nomformation"
    			,'nomdeprojet'=>"nomdeprojet"
    			,"description"=>"Description"
    	);
    	$mapper = new Application_Model_Mapper_Projetregional();
    	$this->view->headercolums=$header;
    	
    	$select=$mapper->fetchAllToArray();
    	//ajouter le requtte a la paginateur
    	$paginator = Zend_Paginator::factory($select);
    	//ajouter le nombre d'enregistrement par page
    	$paginator->setItemCountPerPage(3);
    	//ajouter la page par defaut
    	$paginator->setCurrentPageNumber($this->_getParam('page', 1));
    	//ajouter le paginateur au view
    	$this->view->paginator = $paginator;
    	 
    	Zend_View_Helper_PaginationControl::setDefaultViewPartial('controls.phtml');
    }

    public function addgestprojetAction()
    {
        // action body
    }

    public function addprojetAction()
    {
        // action body
    	$form=new Application_Form_Projet();
    	$this->view->form=$form;
    	
    	if ($this->_request->isPost()) {
    		$formData = $this->_request->getPost();
    		if ($form->isValid($formData)) {
    			$formation = new Application_Model_DbTable_Projetregional();
    			$row = $formation->createRow();
    	
    			$row->idgoverneras = $form->getValue('Regional');
    			$row->nomdeprojet = $form->getValue('Nom');
    			$row->description = $form->getValue('desc');
    			 
    	
    			$result = $row->save();
    	
    	
    			$this->_helper->redirector("gestfeuille","gfiledata","gcentrale",array("id"=>$this->_request->getParam("id")));
    		}
    	}
    }

    public function addlistprojetAction()
    {
        // action body
    	$form=new Application_Form_Listprojet();
    	$this->view->form=$form;
    	
    	if ($this->_request->isPost()) {
    		$formData = $this->_request->getPost();
    		if ($form->isValid($formData)) {
    			$formation = new Application_Model_DbTable_Listeprojetsregional();
    			$row = $formation->createRow();
    	
    			$row->titre = $form->getValue('Nom');
    			$row->idfichierregionales = $this->_request->getParam("id");
    			 
    	
    			$result = $row->save();
    	
    	
    			$this->_helper->redirector("gestfeuille","gfiledata","gcentrale",array("id"=>$this->_request->getParam("id")));
    		}
    	}
    }

    public function gestlistprojetAction()
    {
        // action body
    	$header=array(
    			"idfeuilles"=>"Code"
    			,"titre"=>"Titre"
    	);
    	$mapper = new Application_Model_Mapper_Feuilles();
    	$this->view->headercolums=$header;
    	 
    	$select=$mapper->fetchAllToArray();
    	//ajouter le requtte a la paginateur
    	$paginator = Zend_Paginator::factory($select);
    	//ajouter le nombre d'enregistrement par page
    	$paginator->setItemCountPerPage(3);
    	//ajouter la page par defaut
    	$paginator->setCurrentPageNumber($this->_getParam('page', 1));
    	//ajouter le paginateur au view
    	$this->view->paginator = $paginator;
    	
    	Zend_View_Helper_PaginationControl::setDefaultViewPartial('controls.phtml');
    }


}











